package com.custom.base.dialog

import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.widget.ScrollView
import android.widget.TextView
import com.custom.base.R
import com.custom.base.util.SDViewUtil.layoutParamsLinearLayoutWW

/**
 * 作者：
 * 时间：2021/1/14
 * 描述：带标题，内容，确定按钮和取消按钮的窗口
 */
class SDDialogConfirm(text: String?) : SDDialogCustom() {
    private lateinit var mTvContent: TextView

    init {
        addTextView()
        if (TextUtils.isEmpty(text)) {
            mTvContent.visibility = View.GONE
        } else {
            mTvContent.visibility = View.VISIBLE
            mTvContent.text = text
        }
    }

    private fun addTextView() {
        val view = LayoutInflater.from(context).inflate(R.layout.dialog_confirm, null)
        mTvContent = view.findViewById(R.id.dialog_confirm_tv_content)
        val params = layoutParamsLinearLayoutWW
        setCustomView(view, params)
    }

    /**
     * 设置内容显示位置
     * @param gravity
     */
    fun setContentGravity(gravity: Int) : SDDialogConfirm {
        mTvContent.gravity = gravity
        return this
    }
}